/*
 * 컴파일을 위해 올려 놓은 소스 입니다.
 * 서버에 반영하지 마시고 다른국가에 적용할 경우 서버에 있는 class 를 카피해서 사용하십시오.
 * 
 */
/*
 * Created on 2004. 9. 29.
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package com.pushmsg.OmaOtaConf.OmaOtaObject;

/**
 * @author dgchun
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class PXPHYSICAL 
{
	private String id = null;
	private String napid = null;
	private String addrtype = "IPV4";
	private String address = null;
	
	public PXPHYSICAL(String op, String napid, String address)
	{
		this.id = op + " Proxy";
		this.napid = napid;
		this.address = address;
	}
	
	public int getData(byte[] buffer, int index)
	{
		int startPos = index;
		//<characteristic type="PXPHYSICAL">
		buffer[index++] = (byte)0xC6;
		buffer[index++] = (byte)0x52;
		buffer[index++] = (byte)0x01;
		//<parm name="PHYSIAL-PROXY-ID" value=""/>
		buffer[index++] = (byte)0x87;
		buffer[index++] = (byte)0x2F;
		buffer[index++] = (byte)0x06;
		buffer[index++] = (byte)0x03;
		System.arraycopy(id.getBytes(), 0, buffer, index, id.length());
		index += id.length();
		buffer[index++] = (byte)0x00;
		buffer[index++] = (byte)0x01;
		//<parm name="PXADDR" value=""/>
		buffer[index++] = (byte)0x87;
		buffer[index++] = (byte)0x20;
		buffer[index++] = (byte)0x06;
		buffer[index++] = (byte)0x03;
		System.arraycopy(address.getBytes(), 0, buffer, index, address.length());
		index += address.length();
		buffer[index++] = (byte)0x00;
		buffer[index++] = (byte)0x01;	
		//<parm name="PXADDRTYPE" value=""/>
		buffer[index++] = (byte)0x87;
		buffer[index++] = (byte)0x21;
		buffer[index++] = (byte)0x06;
		if(addrtype.equals("IPV4"))			
			buffer[index++] = (byte)0x85;		
		buffer[index++] = (byte)0x01;
		//<parm name="TO-NAPID" value=""/>
		buffer[index++] = (byte)0x87;
		buffer[index++] = (byte)0x22;
		buffer[index++] = (byte)0x06;
		buffer[index++] = (byte)0x03;
		System.arraycopy(napid.getBytes(), 0, buffer, index, napid.length());
		index += napid.length();
		buffer[index++] = (byte)0x00;
		buffer[index++] = (byte)0x01;
		buffer[index++] = (byte)0x01;
		
		return index - startPos;
	}
	
}
